package org.edu.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
/**<h2>医院科室表</h2>
 * <p>该表详细配置了科室与科室树one-to-one的关系</P>
 * 
 * @author 谢圣强
 * @version 1.1
 * @see TreeNode
 */

@Entity
@Table(name = "T_dept")
public class Dept {
	private int deptno; // 科室编号
	private String deptname; // 科室名称
	private String deptabb; // 科室缩写
	private String deptpic; // 科室负责人
	private String deptp; // 科室属性
	
	private TreeNode treenode;
	public Dept(){}
	public Dept(String[] str){
		this.deptno=Integer.parseInt(str[0]);
		this.deptname=str[1];
		this.deptabb=str[2];
		this.deptpic=str[3];
		this.deptp=str[4];
	}
	@Id
	@GeneratedValue(generator="pkGenerator")
	@GenericGenerator(name="pkGenerator",
	            strategy="foreign",
	            parameters={@Parameter(name="property",value="treenode")})
	public int getDeptno() {
		return deptno;
	}
	public void setDeptno(int deptno) {
		this.deptno = deptno;
	}
	@Column(name="tb_deptname",nullable = true)
	public String getDeptname() {
		return deptname;
	}

	@Column(name="tb_deptabb")
	public String getDeptabb() {
		return deptabb;
	}

	@Column(name="tb_deptpic")
	public String getDeptpic() {
		return deptpic;
	}

	@Column(name="tb_deptp")
	public String getDeptp() {
		return deptp;
	}

	
	public void setDeptname(String deptname) {
		this.deptname = deptname;
	}
	public void setDeptabb(String deptabb) {
		this.deptabb = deptabb;
	}
	public void setDeptpic(String deptpic) {
		this.deptpic = deptpic;
	}
	public void setDeptp(String deptp) {
		this.deptp = deptp;
	}
	@OneToOne(cascade=CascadeType.ALL)
	@PrimaryKeyJoinColumn
	public TreeNode getTreenode() {
		return treenode;
	}
	public void setTreenode(TreeNode treenode) {
		this.treenode = treenode;
	}
	public void setMsg(String[] str) {
		this.deptno=Integer.parseInt(str[0]);
		this.deptname=str[1];
		this.deptabb=str[2];
		this.deptpic=str[3];
		this.deptp=str[4];
		
	}
	public Dept(int deptno, String deptname, String deptabb) {
		super();
		this.deptno = deptno;
		this.deptname = deptname;
		this.deptabb = deptabb;
	}
	
	
}
